package com.example.springrabbitmq.listener;

import com.example.springrabbitmq.constant.Constants;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@RabbitListener(queues = Constants.WORK_QUEUE)
@Component
public class WorkListener {
    @RabbitHandler
    public void queueListener1(Message message) {
        System.out.println("listener 1 [" + Constants.WORK_QUEUE + "] 接收到消息" + message);
    }

    @RabbitHandler
    public void queueListener2(String message, Channel channel) {
        System.out.println("listener 2 [" + Constants.WORK_QUEUE + "] 接收到消息" + message + channel);
    }
}
